package com.kaussoft.lolblog;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class ApplicationContextFactory {

	private static Log log = LogFactory.getLog(ApplicationContextFactory.class);
	private static String[] xmlConfig = null;

	public static void init(String[] xmlInitConfig) {
		xmlConfig = xmlInitConfig;
	}
	
	public static ApplicationContext getApplicationContext(){
		if (xmlConfig == null){
			String error = "Application context not initialized";
			log.error(error);
			throw new IllegalStateException(error);
		}
		else {
			return new FileSystemXmlApplicationContext(xmlConfig);
			//return new ClassPathXmlApplicationContext(xmlConfig);
		}
	}
}
